package com.sujeet.learning.xml;

import java.io.File;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
// Parser import
import org.apache.xerces.parsers.DOMParser;

public class SerializerTest {
	public void test(String xmlDocument, String outputFilename)
			throws Exception {
		File outputFile = new File(outputFilename);
		DOMParser parser = new DOMParser();
		// Get the DOM tree as a Document object
		parser.parse(xmlDocument);
		Document doc = parser.getDocument( );
		// Serialize
		DOMSerializer serializer = new DOMSerializer( );
		serializer.serialize(doc, new File(outputFilename));
	}
	
	public static void main(String[] args) {

		try {
			SerializerTest tester = new SerializerTest();
			tester.test(
					"src/main/resources/com/sujeet/learning/xml/contents.xml",
					"/tmp/out.xml");
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
